Package nz.ac.massey.softwarec.group3.game

Source Code of nz.ac.massey.softwarec.group3.game.PlayerInterfaceTest

package nz.ac.massey.softwarec.group3.game;

import nz.ac.massey.softwarec.group3.game.map.MapStation;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

/**
*
* @author craigspence & natalie eustace
*/
public class PlayerInterfaceTest {
   
    private Player player;
    private int taxiTokens;
    private int busTokens;
    private int undergroundTokens;
    private MapStation currentLocation;
    private Boolean ready;
   
    public PlayerInterfaceTest() {
    }
   
    @Before
    public void setUp() {
        player = new Player(1,2,3,true); //player in this case is Mr X.
        taxiTokens = 0;
        busTokens = 1;
        undergroundTokens = 2;
        currentLocation = new MapStation(1, 1.0, 1.0);
        ready = false;
    }
   
    @After
    public void tearDown() {
        player = null;
        taxiTokens = 0;
        busTokens = 0;
        undergroundTokens = 0;
        currentLocation = null;
        ready = false;
    }

   
    /**
     * Test of givePlayerTravelToken method, of class PlayerInterface.
     */
    @Test
    public void givePlayerTravelToken(){
        int beforeTaxiTokens = player.getTaxiTokens();
        player.giveTravelToken(taxiTokens);
        int result = player.getTaxiTokens();
        int expTaxiTokens = beforeTaxiTokens+1;
        assertEquals(expTaxiTokens, result);
       
        int beforeBusTokens = player.getBusTokens();
        player.giveTravelToken(busTokens);
        int result2 = player.getBusTokens();
        int expBusTokens = beforeBusTokens+1;
        assertEquals(expBusTokens, result2);
       
        int beforeUndergroundTokens = player.getUndergroundTokens();
        player.giveTravelToken(undergroundTokens);
        int result3 = player.getUndergroundTokens();
        int expUndergroundTokens = beforeUndergroundTokens+1;
        assertEquals(expUndergroundTokens, result3);
   
    }
   
    /**
     * Test of getCurrentLocation & setCurrentLocation method, of class PlayerInterface.
     */
    @Test
    public void getCurrentLocation() {
        System.out.println("getCurrentLocation & setCurrentLocation");
        player.setCurrentLocation(currentLocation);
        MapStation result = player.getCurrentLocation();
        assertEquals(currentLocation, result);
       
    }
   
    /**
     * Test of isReady & setReady method, of class PlayerInterface.
     */
    @Test
        public void isReady() {
        player.setReady(true);
        boolean expResult = true;
        boolean result = player.isReady();
        assertEquals(expResult, result);
    }
   
    /**
     * Test of isReady & setReady method, of class PlayerInterface.
     */
    @Test
        public void isMrX() {
        boolean expResult = true;
        boolean result = player.isMrX();
        assertEquals(expResult, result);
    }
   
    /**
     * Test of useBusToken method, of class PlayerInterface.
     */
    @Test
    public void testUseBusToken() {
        System.out.println("useBusToken");
        int preBusTokens = player.getBusTokens();
        player.useBusToken();
        int postBusTokens = player.getBusTokens();
        assertEquals(preBusTokens - 1, postBusTokens);
    }

    /**
     * Test of useTaxiToken method, of class PlayerInterface.
     */
    @Test
    public void testUseTaxiToken() {
        System.out.println("useTaxiToken");
        int preTaxiTokens = player.getTaxiTokens();
        player.useTaxiToken();
        int postTaxiTokens = player.getTaxiTokens();
        assertEquals(preTaxiTokens - 1, postTaxiTokens);
    }

    /**
     * Test of useUndergroundToken method, of class PlayerInterface.
     */
    @Test
    public void testUseUndergroundToken() {
        System.out.println("useUndergroundToken");
        int preUndergroundTokens = player.getUndergroundTokens();
        player.useUndergroundToken();
        int postUndergroundTokens = player.getUndergroundTokens();
        assertEquals(preUndergroundTokens - 1, postUndergroundTokens);
    }

   
    /**
     * Test of compareTo method, of class PlayerInterface.
     */
    @Test
    public void testCompareTo1() {
        System.out.println("compareDetectiveToDetective");
        Player detective1 = new Detective();
        Player detective2 = new Detective();
        assertTrue(detective1.compareTo(detective2) == 0);
    }
   
    /**
     * Test of compareTo method, of class PlayerInterface.
     */
    @Test
    public void testCompareTo2() {
        System.out.println("compareDetectiveToMrX");
        Player detective1 = new Detective();
        Player detective2 = new MrX();
        assertTrue(detective1.compareTo(detective2) == 1);
    }
   
    /**
     * Test of compareTo method, of class PlayerInterface.
     */
    @Test
    public void testCompareTo3() {
        System.out.println("compareMrXToDetective");
        Player detective1 = new MrX();
        Player detective2 = new Detective();
        assertTrue(detective1.compareTo(detective2) == -1);
    }
}
TOP

Related Classes of nz.ac.massey.softwarec.group3.game.PlayerInterfaceTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.